<?php
Globals::requireController('Admin');
Globals::requireTable('Config');

class ConfigsController extends AdminController
{
    protected $ConfigTable;
    
	public function __construct($config = null)
	{
		parent::__construct($config, true);
		$this->ConfigTable = new ConfigTable($config);
	}
	
	public function indexAction()
	{
	    $id = $this->getIntParam('id');
	    $value = $this->ConfigTable->getRow($id);
	    $this->view->data = $value;
	}
	
	
	public function doaddAction()
	{
	    $id = $this->getIntParam('id');
	    $data['value'] = $this->getParam('value');
	    
	    $this->ConfigTable->update($data,$id);
	    
	    $this->redirectToAction('index',array('id'=>$id));
	    exit();
	}
	
	public function uploadapkAction(){
	    $doupload = $this->getIntParam('doupload');
	    if($doupload == 1){
	        Globals::requireClass('UploadFile');
	        $upload = new UploadFile();
	        $upload->allowExts = array("apk");
	        $upload->saveRule = null;
	        $upDir = "../apk/";
	        $upload->savePath = $upDir;
	        
	        if ($upload->upload()){
	            echo 1;
	        }else {
	            echo $upload->getErrorMsg();
	        }
	        exit();
	    }
	    
	    
	}
	
	
	
}
